package guowenlong.golf.ui.news;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import guowenlong.golf.R;
import guowenlong.golf.base.BaseFragment;
import guowenlong.golf.ui.home.TabAdapter;
import guowenlong.golf.ui.news.finished.FinishFragment;
import guowenlong.golf.ui.news.hold.HoldFragment;
import guowenlong.golf.ui.news.processing.ProcesFragment;

/**
 * des   : 描述 author: Administrator email : guowenlong20000@gmail.com time  : 2017年02月10日 下午 3:19.
 */

public class NewsFragment extends BaseFragment {

  @BindView(R.id.tl_home)
  TabLayout tlHome;
  @BindView(R.id.vp_view)
  ViewPager vpView;
  private FragmentPagerAdapter fAdapter;                               //定义adapter

  private List<Fragment> list_fragment;                                //定义要装fragment的列表
  private List<String> list_title;                                     //tab名称列表

  private FinishFragment mFinishFragment;
  private HoldFragment mHoldFragment;
  private ProcesFragment mProcesFragment;

  @Override
  public int getLayoutId() {
    return R.layout.fragment_news;
  }

  @Override
  public void initData(Bundle savedInstanceState) {

  }

  @Override
  public void initView() {
    mFinishFragment = new FinishFragment();
    mHoldFragment = new HoldFragment();
    mProcesFragment = new ProcesFragment();

    list_fragment = new ArrayList<>();
    list_fragment.add(mProcesFragment);
    list_fragment.add(mHoldFragment);
    list_fragment.add(mFinishFragment);

    list_title = new ArrayList<>();
    list_title.add("进行中");
    list_title.add("未开始");
    list_title.add("已结束");
    tlHome.setTabMode(TabLayout.MODE_FIXED);
    tlHome.addTab(tlHome.newTab().setText(list_title.get(0)));
    tlHome.addTab(tlHome.newTab().setText(list_title.get(1)));
    tlHome.addTab(tlHome.newTab().setText(list_title.get(2)));

    fAdapter = new TabAdapter(getActivity().getSupportFragmentManager(), list_fragment, list_title);

    //viewpager加载adapter
    vpView.setAdapter(fAdapter);
    //tab_FindFragment_title.setViewPager(vp_FindFragment_pager);
    //TabLayout加载viewpager
    tlHome.setupWithViewPager(vpView);
    //tab_FindFragment_title.set
  }
}